package com.sch.www.user.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sch.www.entity.SysRole;
import com.sch.www.entity.SysUserRole;
import com.sch.www.user.mapper.SysRoleMapper;
import com.sch.www.user.service.ISysRoleService;
import com.sch.www.user.service.ISysUserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author admin
 * @since 2019-05-20
 */
@Service
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements ISysRoleService {
    @Autowired
    ISysUserRoleService userRoleService;

    @Override
    public List<SysRole> listByUserId(String userId) {
        List<SysUserRole> sysUserRoleList = userRoleService.listByUserId(userId);
        List<String> roleIdList = new ArrayList<>(sysUserRoleList.size());
        sysUserRoleList.forEach(userRole -> roleIdList.add(userRole.getRoleId()));
        return (List)listByIds( roleIdList);

    }
}
